<template>
  <div class="child">
    <p>我是子组件2</p>
    <button @click="handler">点击我触发子组件自定义事件xxx</button>
    <button @click="$emit('click', 2, 'click')">点击我触发子组件自定义事件click</button>
  </div>
</template>

<script setup lang="ts">
let $emit = defineEmits(['customEvent', 'click']);
const handler =()=>{
  $emit('customEvent', 1, 'handler');
}

</script>

<style scoped>
.child {
  width: 400px;
  height: 200px;
  background: pink;
}
</style>